<?php
/*echo $_REQUEST['pro_id'];
echo $_REQUEST['project_name'];
echo $_REQUEST['project_manager'];
echo $_REQUEST['pro_description'];
echo $_REQUEST['start_date'];
echo $_REQUEST['complete_date'];
ech $_REQUEST['pro_status'];*/
include "../../operations/connection.php";

try {
	$checkExsit = mysql_query("select * from pr_project where (IDView='".$_REQUEST['pro_idview']."' or NameProject='".$_REQUEST['project_name']."') and IDProject != ".$_REQUEST['pro_id']);
	if (mysql_num_rows($checkExsit)==0) {
		$query = "UPDATE pr_project SET IDView = '".$_REQUEST['pro_idview']."',NameProject = '".$_REQUEST['project_name']."', Description = '".$_REQUEST['pro_description']."',
		 IDManager = '".$_REQUEST['project_manager']."', DateStart = '".$_REQUEST['start_date']."', DateComplete = '".$_REQUEST['complete_date']."',
		Status = '".$_REQUEST['pro_status']."' WHERE IDProject = ".$_REQUEST['pro_id'];
		mysql_query($query);
	}else{
		while ($row = mysql_fetch_array($checkExsit)) {	
			$_SESSION['projectexist'] = array($_REQUEST['pro_idview'],$_REQUEST['project_name'],$_REQUEST['project_manager'],$_REQUEST['start_date'],$_REQUEST['complete_date'],$_REQUEST['pro_status'],$_REQUEST['pro_description']);
			if ($row[IDView]==$_REQUEST['pro_idview']) {
				echo 1;
			}else{
				echo 2;
			}
			break;
		}
	}
} catch (Exception $e) {
	mysql_close($connection);
}

mysql_close($connection);
?>